using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;

public class Life : MonoBehaviour
{
    Text life;
    public int maxLife;
    int lifeCount;
    Vector3 orgianlPosition;

    // Start is called before the first frame update
    void Awake()
    {
        orgianlPosition = transform.position;
        life = GameObject.Find("Canvas/Text").GetComponent<Text>();
        life.text = maxLife.ToString();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void Hurt()
    {
        lifeCount--;
        if (lifeCount <= 0)
        {
            transform.position = orgianlPosition;
            lifeCount = 5;
        }
        life.text = lifeCount.ToString();
    }
}
